package cn.johnyu.product.mapper;

import cn.johnyu.commons.dto.ProductDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Select("select * from products")
    List<ProductDto> findAllProducts();
    @Select("select * from products where id = #{id}")
    ProductDto loadProduct(@Param("id") int id);
    @Insert("insert into products (name,stock) values (#{name},#{stock})")
    int addProduct(ProductDto productDto);
    @Update("update products set stock= stock - #{count} where id = #{id}")
    int reduceStock(@Param("id") int id,@Param("count") int count);
}
